﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Caching;

namespace Component
{
    public class Catching:ICatch
    {

        HttpContext context = null;
        #region ICatch Members

        public void PubObject(string key, object item, TimeSpan duration)
        {
            context = HttpContext.Current;
            try
            {
                context.Cache.Add(key, item, null, DateTime.Now + duration, Cache.NoSlidingExpiration, CacheItemPriority.Default, null);
            }
            catch 
            {
                
                //throw;
            }
        }

        public object GetObject(string key)
        {
            context = HttpContext.Current;
            return  context.Cache.Get( key);
        }

        public void RemoveObject(string key)
        {
            context = HttpContext.Current;
            context.Cache.Remove(key);
        }

        #endregion
    }
}
